package com.njcs.test;

import java.io.IOException;
import java.net.ServerSocket;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class OnlyOneFrame extends JFrame{  
    /**
	 * 
	 */
	private static final long serialVersionUID = -8510401209822000322L;

	private OnlyOneFrame(){  
        ServerSocket server;  
        try {  
            server = new ServerSocket(22333);  
            server.isBound();  
        } catch (IOException e) {  
            e.printStackTrace();  
            JOptionPane.showMessageDialog(this, "您已经启动了一个窗体");  
            // 如果端口已经绑定，系统退出，释放内存。  
            System.exit(0);  
        }  
          
        setTitle("Your title");  
        setSize(805, 410);  
        setResizable(false);  
        setLocationRelativeTo(getOwner());  
        setDefaultCloseOperation(EXIT_ON_CLOSE);  
        setVisible(true);  
    }  
      
    public static void main(String[] args) {  
        new OnlyOneFrame();  
    }  
  
}  
